package com.feng.lang;

/**
 * @author 刘兵召
 * 
 */

public class LangTest {
	/**
	 * 
	 * @param n
	 * @return a String parameter result
	 * @print run time of this program
	 */
	static String badLongString(int n){
		String result = "";
		long time1 = System.currentTimeMillis();
		for(int i = 0; i < n; i++){
			result += "A";
		}
		long time2 = System.currentTimeMillis() - time1;
		System.out.println("用+=生成包含"+n+"个String串花费的时间为:"+time2);
		return result;
	}
	/**
	 * 
	 * @param n
	 * @return the StringBuffer Object
	 * @print run time of this program
	 */
	static String goodLongString(int n){
		StringBuffer sb = new StringBuffer();
		long time3 = System.currentTimeMillis();
		for (int i = 0; i < n; i++){
			sb.append("A");
		}
		long time4 = System.currentTimeMillis() - time3;
		System.out.println("用StringBuffer生成包含"+n+"个String串花费的时间为:"+time4);
		return new String(sb);
	}
	/**
	 * @function judge a Character Object is a Digit Object or not
	 * @return boolean Object "var"
	 */
	static boolean isDigitTest(){
		Character ch= '1';
		boolean var = false;
		var = ch.isDigit(ch);
		return var;
	}
	/**
	 * @function judge a Character Object is a Letter Object or not
	 * @return boolean Object "var"
	 */
	static boolean isLetterTest(){
		Character ch= 'b';
		boolean var = false;
		var = ch.isLetter(ch);
		return var;
	}
	/**
	 * @function judge a Character Object is a Letter or a Digit Object or not
	 * @return boolean Object "var"
	 */
	static boolean isLetterOrDigitTest(){
		Character ch= 'b';
		boolean var = false;
		var = ch.isLetterOrDigit(ch);
		return var;
	}
	/**
	 * @function change a  Letter to UppterCase
	 * @return char Object "ch"
	 */
	static char toUppterCaseTest(){
		Character ch= 'b';
		ch = ch.toUpperCase(ch);
		return ch;
	}
	/**
	 * @ the main method
	 * @param args
	 */
	public static void main(String args[]){
		int n = 64000;
		
		badLongString(n);
		goodLongString(n);
//		System.out.println(isDigitTest());
//		System.out.println(isLetterTest());
//		System.out.println(isLetterOrDigitTest());
//		System.out.println(toUppterCaseTest());
	}
}
